package com.huike.web.controller.report;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;


import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 当前用户**在**当天的线索数量**，**商机数量**，**合同数量**，**成交的金额**
     *
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
        return AjaxResult.success(reportService.getTodayInfo());
    }

    /**
     * 查询当前用户待根进的线索，商机，和待分配的线索和商机
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页--商机转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam String beginCreateTime,
                                               @RequestParam String endCreateTime) {
        List<Map<String, Object>> data = reportService.businessChangeStatistics(beginCreateTime, endCreateTime);
        return AjaxResult.success(data);
    }

    /**
     * 线索转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@RequestParam String beginCreateTime,
                                     @RequestParam String endCreateTime) {
        List<Map<String, Object>> data = reportService.salesStatistic(beginCreateTime, endCreateTime);
        return AjaxResult.success(data);
    }
}